package com.yolo.demo.controller;

import com.yolo.demo.feign.GoodsFeignClient;
import com.yolo.demo.model.Goods;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.List;

@RestController
@RequestMapping("/order")
@Slf4j
public class OrderController {
    @Autowired
    private GoodsFeignClient goodsFeignClient;

    @GetMapping("/goods/{id}")
    public Goods findOne(@PathVariable("id") int id){
        Goods goods = goodsFeignClient.findOne(id);
        log.info("feign接口调用结果{}",goods);
        return goods;
    }

    @GetMapping("/test")
    public String threeSeconds(){
        String seconds = goodsFeignClient.threeSeconds();
        log.info("feign接口调用结果{}",seconds);
        return seconds;
    }
}
